package org.example;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class ExampleMain2 {
    public static void main(String[] args) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("my-persistence-unit");
        EntityManager em = emf.createEntityManager();
        EntityB entityB = new EntityB();
        entityB.setStringB("stringB");
        EntityA entityA = new EntityA();
        entityA.setStringA("stringA");
        entityA.setEntityB(entityB);
        em.getTransaction().begin();
        em.persist(entityA);
        em.persist(entityB);
        em.getTransaction().commit();
        Util.nativeQuery(em,"select * from EntityA");
        Util.nativeQuery(em,"select * from EntityB");
        emf.close();
    }
}
